/**
 * Copyright 2007-2008 Vidar Svansson
 *     
 * This file is part of JAdapter.
 * 
 * JAdapter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * JAdapter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with JAdapter.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jadapter.registry;


import org.jadapter.Adapter;
import org.jadapter.Transformer;

/**
 * The main interface to the JAdapter API for client code.
 * Provides methods both to register adapters, and more importantly, 
 * to use them.
 * 
 * 
 * @author Vidar Svansson
 * @since 0.1
 * 
 * @see AbstractAdapterRegistry
 * @see TransitiveAdapterRegistry
 */
public interface AdapterRegistry {
        
    /** 
     * Get an instance of the given some context object 
     * This is the main method.
     * @param context The object to transform.
     * @param type The desired type to transform to.
     * 
     * @return an instance of T if it is possible to transform
     * the context to the type.
     * 
     * @since 0.1
     */
    public <T> T transform(Object context, Class<T> type) ;
    
   
    /** 
     * Register framework adapters. 
     * @param adapters The adapters to register.
     */
    public void register(Adapter<?, ?> ... adapters);
    

    /** 
     * Register a framework adapter 
     * @param adapter The adapter to register.
     */
    public void register(Adapter<?, ?> adapter);
    
    /**
     * Register a class that by reflection can act as an adapter. 
     * @param adapter The adapter class. 
     * @param provides The type provided by this adapter.
     * @param adaptable The supported input type.
     */
    public <I,C> void register(
            Class<?> adapter, 
            Class<I> provides,
            Class<C> adaptable) ;
    
    /**
     * Register a {@link Transformer} as an adapter.
     * @param adapter The transformer to register.
     * @param provides The type provided by this adapter.
     * @param context The supported input type.
     */
    public <I,C> void register(
            Transformer<I,C> adapter,
            Class<I> provides,
            Class<C> context);
    
    
    /** 
     * Register multiple adapters.
     * @param adapters Adapters to register.
     * @since 0.1
     */
    public void registerAdapters(Iterable<Adapter<?,?>> adapters);  
    

}
